package com.foreveross.fetl.core.domain.task.repository.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.foreveross.fetl.common.jpa.EntityHibernateRepository;
import com.foreveross.fetl.core.domain.task.TaskTemplateAssignDayEntity;
import com.foreveross.fetl.core.domain.task.repository.ITaskTemplateAssignDayRepository;

@Repository("taskTemplateAssignDayRepository")
public class TaskTemplateAssignDayRepositoryImpl extends
		EntityHibernateRepository implements ITaskTemplateAssignDayRepository {

	@Override
	public List<TaskTemplateAssignDayEntity> findByCondition(Long templateId) {
		StringBuffer jpql = new StringBuffer(
				"select ttade from TaskTemplateAssignDayEntity ttade where 1=1");
		List<Object> conditionVals = new ArrayList<Object>();
		if (templateId != null) {
			jpql.append(" and ttade.templateId =?");
			conditionVals.add(templateId);
		}
		return super.queryResult(jpql.toString(), conditionVals.toArray());
	}

}
